﻿using Dapper;
using System.Data.SqlClient;
using System.Linq;
using System.Data;
using System.Configuration;
using Ct.StudentProject.StudentModel;
using System;
namespace Ct.StudentProject.Repository
{
    public class StudentRepository
    {
        //public SqlConnection StudentConnection ()
        //{
     
        //    return conn;
        //}

        public int InsertStudent(RegisterStudent stu)
        {
            var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlConnectionString"].ConnectionString);
            using (conn)
            {
                conn.Open();

                //tblUser
                string sql = "INSERT INTO tblUser(userName,name,passWord,IDNumber)VALUES(@userName,@name,@passWord,@IDNumber);SELECT SCOPE_IDENTITY();";
              //  int ID = conn.Execute(sql, stu);
                int ID = Convert.ToInt32(conn.Execute(sql, stu));
                SqlCommand cmd = new SqlCommand(sql, conn);
                //bug
                return ID;
            }
        }
        
    }

}